package com.hue.gulimail.gulimailorder.web;

import com.hue.gulimail.gulimailorder.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author: 姚凤桥
 * @Date: 2021/12/30 22:37
 * @Description:
 */
@RestController
@RequestMapping("/test")
public class TestMqController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/sendOrderMsg")
    public String sendOrderMsg() {
        OrderEntity order = new OrderEntity();
        order.setId(1L);
        order.setPayAmount(new BigDecimal(10000));
        order.setNote("测试订单");
        order.setMemberUsername("姚凤桥");
        order.setReceiverProvince("湖北省");
        order.setModifyTime(new Date());
        System.out.println("订单创建成功:" + new Date());
        rabbitTemplate.convertAndSend("order-event-exchange", "order.create.queue", order);
        return "发送成功";
    }
}
